<?php

include("../utility/connection.php");
include("../model/mFile.php");
include("../model/mPaper.php");
session_start();

if ($_SERVER["REQUEST_METHOD"] == "POST") {

    $PaperId = trim(mysql_real_escape_string($_POST["hidPaperId"]));
    $result = fnSelectFile($PaperId);
    list($filename, $fileblob, $filesize, $filetype) = mysql_fetch_array($result);

    header("Content-length: $filesize");
    header("Content-type: $filetype");
    header("Content-Disposition: attachment; filename=$filename");
    echo $fileblob;

}
?>
